<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    /*
    # 4、获取当前 localstorage 能够使用的最大大小
    */
    let ac="123456789000";
    let ca='';
    for(let i=0;i<ac.length;i++){
        ca=ca+ac;
    }
    let sum="";
    let i=0;
    while(i<512){
        i++;
        try{
            sum+=ca;
            console.log((sum.length/1024/1024).toFixed(3),"M");
            localStorage.removeItem("sum");
            localStorage.getItem("sum",sum);
        }catch(e){
            console.log((sum.length/1024/1024).toFixed(3),"M");
        }
    }
</script>
</html>